import Vue from "vue";
import Router from "vue-router";
import i18n from "../lang";
/* Layout */
import Layout from "@/layout";
/**
 * Note: 路由配置项
 *
 * hidden: true                     // 当设置 true 的时候该路由不会再侧边栏出现 如401，login等页面，或者如一些编辑页面/edit/1
 * alwaysShow: true                 // 当你一个路由下面的 children 声明的路由大于1个时，自动会变成嵌套的模式--如组件页面
 *                                  // 只有一个时，会将那个子路由当做根路由显示在侧边栏--如引导页面
 *                                  // 若你想不管路由下面的 children 声明的个数都显示你的根路由
 *                                  // 你可以设置 alwaysShow: true，这样它就会忽略之前定义的规则，一直显示根路由
 * redirect: noRedirect             // 当设置 noRedirect 的时候该路由在面包屑导航中不可被点击
 * name:'router-name'               // 设定路由的名字，一定要填写不然使用<keep-alive>时会出现各种问题
 * query: '{"id": 1, "name": "ry"}' // 访问路由的默认传递参数
 * meta : {
    noCache: true                   // 如果设置为true，则不会被 <keep-alive> 缓存(默认 false)
    title: 'title'                  // 设置该路由在侧边栏和面包屑中展示的名字
    icon: 'svg-name'                // 设置该路由的图标，对应路径src/assets/icons/svg
    breadcrumb: false               // 如果设置为false，则不会在breadcrumb面包屑中显示
    activeMenu: '/system/user'      // 当路由设置了该属性，则会高亮相对应的侧边栏。
  }
 */
import transferRulesRoute from './transferRules'

Vue.use(Router);

// 公共路由
export const constantRoutes = [
  {
    path: "/redirect",
    component: Layout,
    hidden: true,
    children: [
      {
        path: "/redirect/:path(.*)",
        component: (resolve) => require(["@/views/redirect"], resolve),
      },
    ],
  },
  {
    path: "/login",
    component: (resolve) => require(["@/views/login"], resolve),
    hidden: true,
  },
  {
    path: "/register",
    component: (resolve) => require(["@/views/register"], resolve),
    hidden: true,
  },
  {
    path: "/404",
    component: (resolve) => require(["@/views/error/404"], resolve),
    hidden: true,
  },
  {
    path: "/401",
    component: (resolve) => require(["@/views/error/401"], resolve),
    hidden: true,
  },
  // {
  //   path: "/basic/typeInspectionDataSharing",
  //   name: "typeInspectionDataSharing",
  //   title: "型式物料绑定",
  //   component: (resolve) =>
  //     require([
  //       "@/views/basic/typeInspectionDataSharing/index",
  //     ], resolve),
  //   meta: { title: "型式物料绑定" },
  // },
  {
    path: "/",
    component: Layout,
    redirect: "index",
    children: [
      {
        path: "index",
        hidden: true,
        component: (resolve) => require(["@/views/home/index"], resolve),
        name: "Index",
        meta: {
          title: i18n.t('routes["/index"]'),
          icon: "dashboard",
          affix: true,
        },
      },
      {
        path: "sample",
        name: "sample",
        title: "抽样方案",
        component: (resolve) =>
          require(["@/views/inspectionManagement/samplingPlan/index"], resolve),
        meta: { title: "抽样方案" },
      },
      {
        path: "inspectionPlan",
        name: "inspectionPlan",
        title: "检验标准",
        component: (resolve) =>
          require([
            "@/views/inspectionManagement/inspectionPlan/index",
          ], resolve),
        meta: { title: "检验标准" },
      },
      {
        path: "inspectedInventory",
        name: "inspectedInventory",
        title: "待检任务",
        component: (resolve) =>
          require([
            "@/views/inventoryManagement/inspectedInventory/index",
          ], resolve),
        meta: { title: "待检任务" },
      },
      {
        path: "outliers",
        name: "outliers",
        title: "异常点清单",
        component: (resolve) =>
          require(["@/views/specimenManagement/outliers/index"], resolve),
        meta: { title: "异常点清单" },
      },
      {
        path: "specimen",
        name: "specimen",
        title: "样品管理",
        component: (resolve) =>
          require(["@/views/specimenManagement/specimen/index"], resolve),
        meta: { title: "样品管理" },
      },
      //   {
      //     path: 'compdemo',
      //     name: 'compdemo',
      //     component: (resolve) => require(['@/views/compDemo/index'], resolve),
      //     meta: { title: '组件库' }
      //   },
    ],
  },
  {
    path: "/flowTemplate/add",
    component: Layout,
    hidden: true,
    redirect: "noredirect",
    children: [
      {
        path: "index",
        component: (resolve) => require(["@/views/flowTemplate/add"], resolve),
        title: "新增流程模板",
        name: "addFlowTemplate",
        meta: {
          title: "新增流程模板",
          subLocalRouter: true,
          activeMenu: "/flowTemplate",
        },
      },
    ],
  },
  {
    path: "/flowTemplate/edit",
    component: Layout,
    hidden: true,
    redirect: "noredirect",
    children: [
      {
        path: "index/:id",
        component: (resolve) => require(["@/views/flowTemplate/add"], resolve),
        title: "编辑流程模板",
        name: "addFlowTemplate",
        meta: {
          title: "编辑流程模板",
          subLocalRouter: true,
          activeMenu: "/flowTemplate",
        },
      },
    ],
  },
  {
    path: "/flowTemplate/view",
    component: Layout,
    hidden: true,
    redirect: "noredirect",
    children: [
      {
        path: "index/:id",
        component: (resolve) => require(["@/views/flowTemplate/add"], resolve),
        title: "查看流程模板",
        name: "viewFlowTemplate",
        meta: {
          title: "查看流程模板",
          subLocalRouter: true,
          activeMenu: "/flowTemplate",
        },
      },
    ],
  },
  {
    path: "/inventoryInspection/add",
    component: Layout,
    hidden: true,
    redirect: "noredirect",
    children: [
      {
        path: "index/:id",
        component: (resolve) =>
          require([
            "@/views/inventoryManagement/inventoryInspection/add",
          ], resolve),
        title: "新增库存检验",
        name: "addInventoryInspection",
        meta: {
          title: "新增库存检验",
          subLocalRouter: true,
          activeMenu: "/inventoryManagement/inventoryInspection",
        },
      },
    ],
  },
  {
    path: "/inventoryInspection/detail",
    component: Layout,
    hidden: true,
    redirect: "noredirect",
    children: [
      {
        path: "index/:id",
        component: (resolve) =>
          require([
            "@/views/inventoryManagement/inventoryInspection/add",
          ], resolve),
        title: "查看库存检验",
        name: "addInventoryInspection",
        meta: {
          title: "查看库存检验",
          subLocalRouter: true,
          activeMenu: "/inventoryManagement/inventoryInspection",
        },
      },
    ],
  },
  {
    path: "/additionalInspection/add",
    component: Layout,
    hidden: true,
    redirect: "noredirect",
    children: [
      {
        path: "index/:id",
        component: (resolve) =>
          require([
            "@/views/inventoryManagement/additionalInspection/add",
          ], resolve),
        title: "新增额外检验单",
        name: "additionalInspection",
        meta: {
          title: "新增额外检验单",
          subLocalRouter: true,
          activeMenu: "/inventoryManagement/additionalInspection",
        },
      },
    ],
  },
  {
    path: "/message",
    component: Layout,
    hidden: true,
    redirect: "noredirect",
    children: [
      {
        path: "list",
        component: (resolve) =>
          require(["@/views/system/message/index"], resolve),
        name: "message-list",
        meta: { title: "待阅消息", icon: "user" },
      },
    ],
  },

  {
    path: "/additionalInspection/edit",
    component: Layout,
    hidden: true,
    redirect: "noredirect",
    children: [
      {
        path: "index/:id",
        component: (resolve) =>
          require([
            "@/views/inventoryManagement/additionalInspection/add",
          ], resolve),
        title: "编辑额外检验单",
        name: "additionalInspection",
        meta: {
          title: "编辑额外检验单",
          subLocalRouter: true,
          activeMenu: "/inventoryManagement/additionalInspection",
        },
      },
    ],
  },
  {
    path: "/additionalInspection/detail",
    component: Layout,
    hidden: true,
    redirect: "noredirect",
    children: [
      {
        path: "index/:id",
        component: (resolve) =>
          require([
            "@/views/inventoryManagement/additionalInspection/add",
          ], resolve),
        title: "查看额外检验单",
        name: "additionalInspection",
        meta: {
          title: "查看额外检验单",
          subLocalRouter: true,
          activeMenu: "/inventoryManagement/additionalInspection",
        },
      },
    ],
  },

  {
    path: "/reviewUnqualified/detail",
    component: Layout,
    hidden: true,
    redirect: "noredirect",
    children: [
      {
        path: "index/:id",
        component: (resolve) =>
          require([
            "@/views/inventoryManagement/reviewUnqualified/detail",
          ], resolve),
        title: "查看不合格评审单",
        name: "reviewUnqualifiedDetail",
        meta: {
          title: "查看不合格评审单",
          subLocalRouter: true,
          activeMenu: "/inventoryManagement/reviewUnqualified",
        },
      },
    ],
  },
  {
    path: "/addInspectionPlan",
    component: Layout,
    hidden: true,
    redirect: "noredirect",
    children: [
      {
        path: "index/:id",
        component: (resolve) =>
          require([
            "@/views/inspectionManagement/inspectionPlan/editInspectionPlan",
          ], resolve),
        title: "新增检验标准",
        name: "addInspectionPlan",
        meta: {
          title: "新增检验标准",
          subLocalRouter: true,
          activeMenu: "/inspect/inspectionPlan",
        },
      },
    ],
  },
  // 新增GAP页面
  {
    path: "/addGap",
    component: Layout,
    hidden: true,
    redirect: "noredirect",
    children: [
      {
        path: "index",
        component: (resolve) => require(["@/views/basic/gap/detial"], resolve),
        title: "新增GAP",
        name: "addGap",
        meta: {
          title: "新增GAP",
          subLocalRouter: true,
          activeMenu: "/inspect/gap",
        },
      },
    ],
  },
  // 版本管理 - 版本对比
  {
    path: "/inspect",
    component: Layout,
    hidden: true,
    redirect: "noredirect",
    children: [
      {
        path: "comparison",
        component: (resolve) =>
          require(["@/views/basic/version/detial"], resolve),
        title: "版本对比",
        name: "comparison",
        meta: {
          title: "版本对比",
          subLocalRouter: true,
          activeMenu: "/inspect/version",
        },
      },
    ],
  },
  {
    path: "/addTemplate",
    component: Layout,
    hidden: true,
    redirect: "noredirect",
    children: [
      {
        path: "index/:id",
        component: (resolve) =>
          require([
            "@/views/inspectionManagement/inspectionPlan/addTemplate",
          ], resolve),
        title: "新增检验标准模板",
        name: "addTemplate",
        meta: {
          title: "新增检验标准模板",
          subLocalRouter: true,
          activeMenu: "/inspectionManagement/inspectionPlan",
        },
      },
    ],
  },
  {
    path: "/editInspectionPlan",
    component: Layout,
    hidden: true,
    redirect: "noredirect",
    children: [
      {
        path: "index/:id",
        component: (resolve) =>
          require([
            "@/views/inspectionManagement/inspectionPlan/editInspectionPlan",
          ], resolve),
        title: "编辑检验标准",
        name: "editInspectionPlan",
        meta: {
          title: "编辑检验标准",
          subLocalRouter: true,
          activeMenu: "/inspectionManagement/inspectionPlan",
        },
      },
    ],
  },
  {
    path: "/inspectionDetail",
    component: Layout,
    hidden: true,
    redirect: "noredirect",
    children: [
      {
        path: "index/:id",
        component: (resolve) =>
          require([
            "@/views/inspectionManagement/inspectionPlan/editInspectionPlan",
          ], resolve),
        title: "检验标准详情",
        name: "inspectionDetail",
        meta: {
          title: "检验标准详情",
          subLocalRouter: true,
          activeMenu: "/inspectionManagement/inspectionPlan",
        },
      },
    ],
  },
  {
    path: "/editTemplate",
    component: Layout,
    hidden: true,
    redirect: "noredirect",
    children: [
      {
        path: "index/:id",
        component: (resolve) =>
          require([
            "@/views/inspectionManagement/inspectionPlan/addTemplate",
          ], resolve),
        title: "编辑检验标准模板",
        name: "editTemplate",
        meta: {
          title: "编辑检验标准模板",
          subLocalRouter: true,
          activeMenu: "/inspectionManagement/inspectionPlan",
        },
      },
    ],
  },

  {
    path: "/batchInspectionPlan",
    component: Layout,
    hidden: true,
    redirect: "noredirect",
    children: [
      {
        path: "index/:id",
        component: (resolve) =>
          require([
            "@/views/inspectionManagement/inspectionPlan/batchInspectionPlan",
          ], resolve),
        title: "批量新增检验标准",
        name: "batchInspectionPlan",
        meta: {
          title: "批量新增检验标准",
          subLocalRouter: true,
          activeMenu: "/inspectionManagement/inspectionPlan",
        },
      },
    ],
  },
  {
    path: "/batchEditPlan",
    component: Layout,
    hidden: true,
    redirect: "noredirect",
    children: [
      {
        path: "index/:id",
        component: (resolve) =>
          require([
            "@/views/inspectionManagement/inspectionPlan/batchEditPlan",
          ], resolve),
        title: "批量修改检验标准",
        name: "batchEditPlan",
        meta: {
          title: "批量修改检验标准",
          subLocalRouter: true,
          activeMenu: "/inspectionManagement/inspectionPlan",
        },
      },
    ],
  },
  {
    path: "/templateDetail",
    component: Layout,
    hidden: true,
    redirect: "noredirect",
    children: [
      {
        path: "index/:id",
        component: (resolve) =>
          require([
            "@/views/inspectionManagement/inspectionPlan/addTemplate",
          ], resolve),
        title: "检验标准模板详情",
        name: "templateDetail",
        meta: {
          title: "检验标准模板详情",
          subLocalRouter: true,
          activeMenu: "/inspectionManagement/inspectionPlan",
        },
      },
    ],
  },
  {
    path: "/incoming",
    component: Layout,
    hidden: true,
    redirect: "noredirect",
    children: [
      {
        path: "printerPreview/:id",
        component: (resolve) =>
          require([
            "@/views/inspectionManagement/incoming/printerPreview",
          ], resolve),
        title: "打印预览",
        name: "printerPreview",
        meta: {
          title: "打印预览",
          subLocalRouter: true,
          activeMenu: "/inspectionManagement/incoming",
        },
      },
    ],
  },
  {
    path: "/addIncoming",
    component: Layout,
    hidden: true,
    redirect: "noredirect",
    children: [
      {
        path: "index/:id",
        component: (resolve) =>
          require([
            "@/views/inspectionManagement/incoming/addIncoming",
          ], resolve),
        title: "新增来料检验",
        name: "addIncoming",
        meta: {
          title: "新增来料检验",
          subLocalRouter: true,
          activeMenu: "/inspectionManagement/incoming",
        },
      },
    ],
  },
  {
    path: "/incomingDetail",
    component: Layout,
    hidden: true,
    redirect: "noredirect",
    children: [
      {
        path: "index/:id",
        component: (resolve) =>
          require([
            "@/views/inspectionManagement/incoming/incomingDetail",
          ], resolve),
        title: "查看来料检验",
        name: "incomingDetail",
        meta: {
          title: "查看来料检验",
          subLocalRouter: true,
          activeMenu: "/inspect/incoming",
        },
      },
      {
        path: "selectUse/:id",
        component: (resolve) =>
          require(["@/views/inspectionManagement/selectUse/index"], resolve),
        title: "挑选使用",
        name: "selectUse",
        meta: {
          title: "挑选使用",
          subLocalRouter: true,
          activeMenu: "/inspect/incoming",
        },
      },
    ],
  },
  {
    path: "/additionData",
    component: Layout,
    hidden: true,
    redirect: "noredirect",
    children: [
      {
        path: "index/:id",
        component: (resolve) =>
          require([
            "@/views/inspectionManagement/incoming/additionData",
          ], resolve),
        title: "补录数据",
        name: "additionData",
        meta: {
          title: "补录数据",
          subLocalRouter: true,
          activeMenu: "/inspectionManagement/incoming",
        },
      },
    ],
  },
  {
    path: "/pass",
    component: Layout,
    hidden: true,
    redirect: "noredirect",
    children: [
      {
        path: "index/:id",
        component: (resolve) =>
          require(["@/views/inspectionManagement/incoming/pass"], resolve),
        title: "紧急放行",
        name: "pass",
        meta: {
          title: "紧急放行",
          subLocalRouter: true,
          activeMenu: "/inspectionManagement/incoming",
        },
      },
    ],
  },
  {
    path: "/tenant/user-auth",
    component: Layout,
    hidden: true,
    children: [
      {
        // path: 'role/:userId(\\d+)',
        path: "role",
        title: "分配角色",
        component: (resolve) =>
          require(["@/views/system/user/authRole"], resolve),
        name: "AuthRole",
        meta: { title: "分配角色", activeMenu: "/tenant/user" },
      },
    ],
  },
  {
    path: "/tenant/role-auth",
    component: Layout,
    hidden: true,
    children: [
      {
        // path: 'user/:roleId(\\d+)',
        path: "user",
        title: "分配用户",
        component: (resolve) =>
          require(["@/views/system/role/authUser"], resolve),
        name: "AuthUser",
        meta: { title: "分配用户", activeMenu: "/tenant/role" },
      },
    ],
  },
  {
    path: "/system/dict-data",
    component: Layout,
    hidden: true,
    children: [
      {
        title: "字典数据",
        path: "index/:dictId(\\d+)",
        component: (resolve) => require(["@/views/system/dict/data"], resolve),
        name: "Data",
        meta: {
          title: "字典数据",
          subLocalRouter: true,
          activeMenu: "/system/dict",
        },
      },
    ],
  },
  {
    path: "/ProjectList",
    component: Layout,
    hidden: true,
    redirect: "noredirect",
    children: [
      {
        title: "项目列表",
        path: "list",
        component: (resolve) =>
          require(["@/views/system/ProjectList/index"], resolve),
        name: "ProjectList",
        meta: { title: "项目列表", icon: "user" },
      },
    ],
  },
  {
    path: "/user",
    component: Layout,
    hidden: true,
    redirect: "noredirect",
    children: [
      {
        path: "profile",
        component: (resolve) =>
          require(["@/views/system/user/profile/index"], resolve),
        name: "Profile",
        meta: { title: "个人信息", icon: "user" },
      },
    ],
  },
  {
    path: "/enterprise",
    component: Layout,
    hidden: true,
    redirect: "noredirect",
    children: [
      {
        path: "profile",
        component: (resolve) =>
          require(["@/views/system/enterprise/profile/index"], resolve),
        name: "ent-profile",
        meta: { title: i18n.t('routes["/enterprise/profile"]'), icon: "user" },
      },
    ],
  },
  {
    path: "/callback",
    name: "callback",
    component: () => import("@/views/callback"),
  },
  {
    path: "/addSpecimen",
    component: Layout,
    hidden: true,
    redirect: "noredirect",
    children: [
      {
        path: "index",
        component: (resolve) =>
          require(["@/views/specimenManagement/addSpecimen"], resolve),
        title: "新增样品管理",
        name: "addSpecimen",
        meta: {
          title: "新增样品管理",
          subLocalRouter: true,
          activeMenu: "/specimenManagement/addSpecimen",
        },
      },
    ],
  },
  {
    path: "/outliers/detail",
    component: Layout,
    hidden: true,
    redirect: "noredirect",
    children: [
      {
        path: "index/:id",
        component: (resolve) =>
          require(["@/views/specimenManagement/outliers/detail"], resolve),
        title: "异常点清单详情",
        name: "aoutliersDetail",
        meta: {
          title: "异常点清单详情",
          subLocalRouter: true,
          activeMenu: "/outliers/detail",
        },
      },
    ],
  },
  {
    path: "/scrap",
    component: Layout,
    hidden: true,
    redirect: "noredirect",
    children: [
      {
        path: "index",
        component: (resolve) =>
          require(["@/views/specimenManagement/scrap"], resolve),
        title: "样品申请报废",
        name: "scrap",
        meta: {
          title: "样品申请报废",
          subLocalRouter: true,
          activeMenu: "/specimenManagement/scrap",
        },
      },
    ],
  },
  {
    path: "/specimenCheck",
    component: Layout,
    hidden: true,
    redirect: "noredirect",
    children: [
      {
        path: "index",
        component: (resolve) =>
          require(["@/views/specimenManagement/check"], resolve),
        title: "样品详情",
        name: "specimenCheck",
        meta: {
          title: "样品详情",
          subLocalRouter: true,
          activeMenu: "/specimenManagement/check",
        },
      },
    ],
  },
  {
    path: "/specimenDisplace",
    component: Layout,
    hidden: true,
    redirect: "noredirect",
    children: [
      {
        path: "index",
        component: (resolve) =>
          require(["@/views/specimenManagement/displace"], resolve),
        title: "样品替换",
        name: "specimenDisplace",
        meta: {
          title: "样品替换",
          subLocalRouter: true,
          activeMenu: "/specimenManagement/displace",
        },
      },
    ],
  },
  {
    path: "/abnormalMaterial",
    component: Layout,
    hidden: true,
    redirect: "noredirect",
    children: [
      {
        path: "index",
        component: (resolve) =>
          require(["@/views/statistics/abnormalMaterial/index"], resolve),
        title: "月度异常物料对比",
        name: "abnormalMaterial",
        meta: {
          title: "月度异常物料对比",
          subLocalRouter: true,
          activeMenu: "/statistics/abnormalMaterial",
        },
      },
    ],
  },
  {
    path: "/inventory/addMrbReview",
    component: Layout,
    hidden: true,
    redirect: "noredirect",
    children: [
      {
        path: ":id",
        component: (resolve) =>
          require([
            "@/views/inventoryManagement/ncrList/operateTemplate",
          ], resolve),
        title: "发起MRB评审",
        name: "AddMrbReview",
        meta: {
          title: "发起MRB评审",
          subLocalRouter: true,
          activeMenu: "/inspectionManagement/inspectionPlan",
        },
      },
    ],
  },
  {
    path: "/inventory/mrbReview",
    component: Layout,
    hidden: true,
    redirect: "noredirect",
    children: [
      {
        path: ":id",
        component: (resolve) =>
          require([
            "@/views/inventoryManagement/ncrList/operateTemplate",
          ], resolve),
        title: "查看MRB评审单详情",
        name: "MrbReview",
        meta: {
          title: "查看MRB评审单详情",
          subLocalRouter: true,
          activeMenu: "/inspectionManagement/inspectionPlan",
        },
      },
    ],
  },
  transferRulesRoute,
  {
    path: "/inventoryManagement",
    component: Layout,
    hidden: true,
    redirect: "/inventoryManagement/index",
    children: [

      {
        path: "trialinvestment",
        component: (resolve) =>
          require(["@/views/inventoryManagement/trialinvestment"], resolve),
        title: "试投清单",
        name: "trialinvestment",
        meta: {
          title: "试投清单",
          subLocalRouter: true,
          activeMenu: "/inventoryManagement/trialinvestment",
        },
      },

    ],
},
  {
    name: 'dashboardCockpit',
    path: '/dashboardCockpit',
    component: (resolve) => require(['@/views/dashboardCockpit/index'], resolve),
    meta: { title: '管理指标', icon: 'dashboard' }
  },{
    name: 'processVsibility',
    path: '/processVsibility',
    component: (resolve) => require(['@/views/processVsibility/index'], resolve),
    meta: { title: '可视过程', icon: 'dashboard' }
  }, {
    path: "/costShift",
    component: Layout,
    hidden: true,
    children: [

      {
        path: "costForm/:id",
        component: (resolve) => require([ "@/views/costShift/costlist/costForm"], resolve),
        title: "创建费用转嫁单",
        name: "costForm",
        meta: {
          title: "创建费用转嫁单",
          subLocalRouter: true,
          activeMenu: "/costShift/costForm/index",
        },
      },
    ],
  } ,
  {
    path: "/inventoryManagement/typeInspection",
    component: Layout,
    hidden: true,
    children: [

      {
        path: "/inventoryManagement/typeInspection",
        component: (resolve) => require([ "@/views/inventoryManagement/typeInspection"], resolve),
        title: "型式数据查询",
        name: "typeInspection",
        meta: {
          title: "型式数据查询",
          subLocalRouter: true,
          activeMenu: "/inventoryManagement/typeInspection/index",
        },
      },
    ],
  } ,
];
const appName = process.env.VUE_APP_NAME;
export default new Router({
  mode: "history", // 去掉url中的#
  scrollBehavior: () => ({ y: 0 }),
  base: window.__POWERED_BY_QIANKUN__ ? `/${appName}` : "/",
  routes: constantRoutes,
});
